import Vue from 'vue';
import singleSpaVue from 'single-spa-vue';
import Element from 'element-ui';
import 'default-passive-events'; // npm i default-passive-events -S / Chrome51 版本以后，Chrome 增加了新的事件捕获机制－Passive Event Listeners
import './assets/css/element-variables.scss';
import './assets/font/iconfont.css';
import './assets/css/global.scss';
import LazyRender from 'vue-lazy-render'; // 延迟渲染插件

import store from './store/index';
import router from './router';
import App from './App';
import uploader from 'vue-simple-uploader' // 上传插件



import '@/assets/icons';
// import { getTimeDiffrence } from '@/utils/jsCommon.js'
import {
  getIsimData
} from '@/service/getData'; // 统一接口请求方法
Vue.prototype.$EventBus = new Vue();
Vue.config.productionTip = false;
Vue.use(LazyRender);
Vue.use(Element);
Vue.use(uploader);
// 去掉首位的特定字符
function trimChars(chars, str) {
  // 将chars两端添加特殊字符，以确保只去除首尾的chars
  const pattern = `^([${chars}]*)(.*?)([${chars}]*)$`;
  const regex = new RegExp(pattern, 'g');
  const result = str.replace(regex, '$2');
  return result;
}


Vue.filter('filterValues', (value) => {
  // debugger
  if (!value) {
    return '-';
  } else {
    return value;
  }
});

const vueOptions = {
  el: '#bigModel',
  router,
  store,
  render: (h) => h(App),
};

// 判断当前页面使用singleSpa应用,不是就渲染
if (!window.singleSpaNavigate) {
  delete vueOptions.el;
  new Vue(vueOptions).$mount('#app');
}

// singleSpaVue包装一个vue微前端服务对象
const vueLifecycles = singleSpaVue({
  Vue,
  appOptions: vueOptions,
});

export const bootstrap = vueLifecycles.bootstrap; // 启动时
export const mount = vueLifecycles.mount; // 挂载时
export const unmount = vueLifecycles.unmount; // 卸载时

export default vueLifecycles;